<template>
	<view class="content">
		<view class="header">
			<view class="header-left">
				<!-- <image src="../../static/close.png" mode="" @tap="close"></image>
				<span>每日巡检</span> -->
			</view>
			<view class="header-right" @click="danger" v-if="mysearchIpt">
				<image src="../../static/add.png" mode=""></image>
				<span>隐患上报</span>
			</view>
		</view>
 
		<view >
			<view class="ipts">
		 
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>地址</span>
					</view>
					<span class="place-class">{{content.data.address}}</span>
				</view>
				<view class="hengxian"></view>
				 
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>调压箱数</span>
					</view>
					<span class="place-class">{{content.data.box_num}}</span>
				</view>
				<view class="hengxian"></view>
			 
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>已通气户数</span>
					</view>
					<span class="place-class">{{content.data.user_num}}</span>
				</view>
				<view class="hengxian"></view>
		 
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>安全员</span>
					</view>
					<span class="place-class">{{content.data.realname}}</span>
				</view>
				<view class="hengxian"></view>
 
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>身份证号</span>
					</view>
					<span class="place-class">{{content.data.ID_num}}</span>
				</view>
				<view class="hengxian"></view>
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>联系方式</span>
					</view>
					<span class="place-class">{{content.data.mobile}}</span>
				</view>
				<view class="hengxian"></view>
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>安全员考核分数</span>
					</view>
					<span class="place-class">{{content.data.level}}</span>
				</view>
					<view class="hengxian"></view>
			</view>
			<!-- 第二块 -->
			<view class="ipts">
				<!-- 品牌 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>户外管道设备</span>
					</view>
					<view class="place-class">
						<easySelect class="easySelect" style="width:400rpx;height:100%;color: #0000;font-size: 28rpx;color: #fff;text-align: right;" :options="content.config.check_status_1" ref="easySelect"   :value="hwgdsb==''?content.config.check_status_1[0].label:hwgdsb"  @selectOne="brandChange"></easySelect>
					</view>
				</view>
				<view class="hengxian"></view>
				<!-- 实际功率 -->
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>户内管道设施</span>
					</view>
					<view class="place-class">
						<easySelect class="easySelect" style="width:400rpx;height:100%;color: #0000;font-size: 28rpx;color: #fff;text-align: right;" :options="content.config.check_status_2" ref="easySelect" :value="hngdsb==''?content.config.check_status_2[0].label:hngdsb" @selectOne="powerChange"></easySelect>
					</view>
				</view>
				<view class="hengxian"></view>
				
				<view class="info-item">
					<view class="info-item-left">
						<view class="dot"></view>
						<span>工具自检</span>
					</view>
					<view class="place-class">
						<easySelect class="easySelect" style="width:400rpx;height:100%;color: #0000;font-size: 28rpx;color: #fff;text-align: right;" :options="content.config.check_status_3" ref="easySelect" :value="gjzj==''?content.config.check_status_3[0].label:gjzj" @selectOne="gjzjChange"></easySelect>
					</view>
				</view>
				<view class="hengxian"></view>
				 
				 
				<view class="supplement">
					<view class="info-item">
						<view class="info-item-left">
							<view class="dot"></view>
							<span>备注</span>
						</view>
						<span class="place-class">添加备注</span>
					</view>
					<view class="explain">
						<textarea v-model="autoText" maxlength="200" auto-height @input="textChange" class="textArea" value="" placeholder="请补充说明您的需求" />
					</view>
					<view class="suppBottom">
						<view class="danger-img-box">
						</view>
						<view class="num">
							<view class="">{{textNumber}}/200</view>
						</view>
					</view>
				</view>
			</view>
		  
			<view class="btns">
				<view class="btn1 consel" @click="flag= true,searchIpt = ''">取消</view>
				<view class="btn1 save" @click="userPost">保存</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../common/request.js'
	// import easySelect from '../../components/easy-select/easy-select'
	export default{
		// components: {
		// 	easySelect
		// },
		data() {
			return{
				danger_id:'',
				hwgdsb:'',
				hngdsb:'',
				gjzj:'',
 
				content:{},
				types:'',
				mysearchIpt:false,
				searchIpt: '',
				searchIpts: '',
				flag: true,
				token: '',
				last_check: {},
				user_info:{},
				textNumber: 0,
				// 品牌数组
				options: [],
				// 功率数组
				options1: [],
				// 品牌id
				brandId: '',
				// 功率id
				powerId: '',
				// 备注
				autoText:'一切正常',
				// 气表底数
				meter_base_num:'',
				// 默认显示品牌名
				brandName: '',
				// 默认显示功率
				powerName: '',
				// 气表照片地址
				fileImg1: '',
				img1: '',
				// 壁挂炉照片地址
				fileImg2: '',
				img2: '',
				// 燃气罩照片地址
				fileImg3: '',
				img3: '',
				// 是否安检
				isChecked: false,
				isCheckedNum: '',
				// 是否签收
				isChecked1: false,
				isCheckedNum1: '',
				showRecord: true,
				marginBotton1: 100 + 'rpx',
				sbid:''
			}
		},
		onShow() {
			uni.getStorage({
				key: 'token'
			}).then(da => {
				this.token = da[1].data;
				this.getcontent()
			})
		 
		
			 uni.getStorage({
			     key:'hwgdsb',
			 	 success:(res)=>{
					 this.hwgdsb=res.data
				 }
			 })
			 uni.getStorage({
			     key:'hngdsb',
			 	 success:(res)=>{
					 this.hngdsb=res.data
				 }
			 })
			uni.getStorage({
			    key:'gjzj',
				 success:(res)=>{
					 this.gjzj=res.data
				 }
			})
			uni.getStorage({
			    key:'autoText',
				 success:(res)=>{
					 this.autoText=res.data
				 }
			}) 
		},
		onLoad(options) {
			if(options.type){
				this.types=options.type
				this.mysearchIpt = true
			}
			if(options.sbid){
				this.sbid=options.sbid
			}
			if(options.danger_id){
				this.danger_id=options.danger_id
			}
			 
		},
		methods: {
			brandChange(option) {
				this.hwgdsb = option.label
				
			},
			powerChange(option) {
				this.hngdsb = option.label
				 
			},
			gjzjChange(option){
				this.gjzj = option.label
			}, 			 
			textChange(e) {
				if(e.detail.cursor >= 200) {
					uni.showToast({
						title: '最多可以输入200个字',
						icon: 'none'
					})
				}
				this.textNumber = e.detail.cursor
			},
			//获取信息
			getcontent() {
				let that = this
				var cturl=''
				if(this.types==3){
					cturl='/safer/get_base_info'
				}else{
					cturl='/assistant/get_base_info'
				}
				request.request({
					url: cturl,
					method: 'POST',
					data: {
						token: that.token
					}
				}).then(res => {
						that.content = res.data.data
				})
				 
			},
			// 提交保存
			userPost() {
				let that = this
				var cturl=''
				if(this.types==3){
					cturl='/safer/check_upload'
				}else{
					cturl='/assistant/check_upload'
				}

				request.request({
					url: cturl,
					method: 'POST',
					data: {
						 token: that.token,
						 status_1:this.hwgdsb,
						 status_2:this.hngdsb,
						 status_3:this.gjzj,
						mark: this.autoText,
						danger_id:this.danger_id==''?0:this.danger_id
					}
				}).then(res => {
					if(res.data.code == 1) {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
                         setTimeout(()=>{
							 uni.navigateTo({
							 	url:'../index/index'
							 })
						 },1000)   
					}
				})
			},
		 
			danger() {
				console.log('0000');
				
				if(this.hwgdsb!=''){
					uni.setStorage({
					    key:'hwgdsb',
						data:this.hwgdsb
					})
				}  
				if(this.hngdsb!=''){
					uni.setStorage({
					    key:'hngdsb',
						data:this.hngdsb
					})
				}  
				if(this.gjzj!=''){
					uni.setStorage({
					    key:'gjzj',
						data:this.hwgdsb
					})
				}  
				uni.setStorage({
					key:'autoText',
					data:this.autoText
				})
				console.log('通过');
				uni.navigateTo({
					url:'/pagesA/inspection/diaterpepoting?type=' + this.types
				})
				console.log('再次');
			}
		}
	}
</script>

<style lang="scss" scoped>
	
	.header{
		display: flex;
		justify-content:space-between;
		align-items: center;
		padding: 30rpx 30rpx;
		background-color: #fff;
		.header-left{
			display: flex;
			align-items: center;
			font-size: 32rpx;
			font-weight: 500;
			color: #333;
			image{
				width: 28rpx;
				height: 28rpx;
				margin-right: 20rpx;
			}
		}
		.header-right{
			display: flex;
			align-items: center;
			font-size: 28rpx;
			color: #333;
			image{
				width: 52rpx;
				height: 52rpx;
				margin-right: 10rpx;
			}
		}
	}
	.header1{
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		height: 80rpx;
		width: 100%;
		background-color: #003690;
		padding: 0 40rpx;
		.ipt-box{
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 0 20rpx;
			width: 514rpx;
			height: 52rpx;
			background-color: #fff;
			border-radius: 28rpx;
			image{
				width: 32rpx;
				height: 32rpx;
			}
		}
		.header1-right{
			display: flex;
			align-items: center;
			font-size: 32rpx;
			color: #E2ECFB;
			image{
				width: 36rpx;
				height: 36rpx;
			}
		}
	}
	.searShow{
		width: 360rpx;
		height: 254rpx;
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%,-50%);
		image{
			width: 100%;
			height: 100%;
		}
	}
	.dataCont{
		padding-top: 12rpx;
		padding-left: 42rpx;
		padding-right: 30rpx;
		.searTitle{
			font-size: 32rpx;
			font-weight: 600;
			text-align: left;
			color: #333333;
		}
		.searResult{
			display: flex;
			justify-content: space-between;
			.resText{
				font-size: 32rpx;
				font-weight: 400;
				text-align: left;
				color: #777777;
			}
			image{
				width: 36rpx;
				height: 36rpx;
			}
		}
	}
	.ipts{
		background-color: #fff;
	}
	.info-item{
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 32rpx;
		width: 100%;
		height: 100rpx;
		line-height: 100rpx;
		background-color: #fff;
		font-size: 28rpx;
		color: #333;
		
		input{
			flex: 1;
			text-align: right;
		}
		.dot{
			width: 8rpx;
			height: 8rpx;
			background-color: #003690;
			border-radius: 50%;
			margin-right: 10rpx;
		}
		.danger-img{
			width: 75rpx;
			height: 75rpx;
			// border: 2rpx dashed #eee;
			margin-right: 10rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.danger-img-box{
			display: flex;
		}
		
		.info-item-left{
			display: flex;
			align-items: center;
			font-size: 32rpx;
		}
	}
	.hengxian{
		width: 700rpx;
		height: 2rpx;
		background-color:  #eee;
	}
	.place-class{
		font-size: 26rpx;
		color: #999;
	}
	.btn{
		width: 646rpx;
		height: 80rpx;
		margin: 74rpx auto;
		text-align: center;
		line-height: 80rpx;
		border-radius: 40rpx;
		background-image: linear-gradient(to bottom, #2366D5, #001B48);
		font-size: 32rpx;
		color: #E5EFFE;
	}
	.btns{
		position: fixed;
		bottom: 0;
		display: flex;
		width: 100%;
		background: #FFFFFF;
		z-index: 99;
		.btn1{
			width: 50%;
			height: 96rpx;
			line-height: 96rpx;
			text-align: center;
			font-size: 28rpx;
		}
		.consel{
			background-color: #FFFFFF;
			color: #777;
		}
		.save{
			background-color: #003690;
			color: #fff;
		}
	}
	.btn:active{
		background: rgba(0,0,0,0.4);
	}
	.zhanwei{
		height: 250rpx;
	}
	.record{
		display: flex;
		align-items: center;
		color: #003690;
		font-size: 32rpx;
		margin-top: 20rpx;
		image{
			width: 32rpx;
			height: 32rpx;
			margin: 0 20rpx 0 30rpx;
		}
		span{
			font-weight: 700;
		}
	}
	.record-item{
		display: flex;
		justify-content: space-between;
		padding: 10rpx 30rpx;
		border-bottom: 2rpx solid #eee;
		.record-item-left{
			display: flex;
			align-items: center;
			.shu{
				width: 8rpx;
				height: 28rpx;
				background-color: #003690;
				border-radius: 8rpx;
			}
			.title{
				font-size: 32rpx;
				color: #333;
				font-weight: 500;
				margin: 0 10rpx;
			}
			.time{
				font-size: 28rpx;
				color: #777;
			}
		}
		.record-item-right{
			display: flex;
			align-items: center;
			.dianhua{
				width: 28rpx;
				height: 28rpx;
			}
			.zhankai{
				width: 36rpx;
				height: 36rpx;
			}
			.title{
				font-size: 32rpx;
				color: #555;
				font-weight: 500;
				margin: 0 10rpx;
			}
		}
	}
	.supplement{
		margin: 20rpx 28rpx;
		background-color: #fff;
		position: relative;
		overflow: hidden;
		.explain{
			.textArea{
				min-height: 142rpx;
				padding: 14rpx 30rpx;
				font-size: 32rpx;
				text-align: left;
				color: rgba(187,187,187,0.84);
			}
		}
		.suppBottom{
			.danger-img{
				position: relative;
				margin-left: 50rpx;
				margin-bottom: 0rpx;
				width: 68rpx;
				height: 68rpx;
				float: left;
				image{
					width: 36rpx;
					height: 36rpx;
					position: absolute;
					left: 50%;
					top: 50%;
					transform: translate(-50%,-50%);
				}
			}
			.num{
				float: right;
				margin-right: 26rpx;
			}
		}
	}
</style>
